<?php

/**
 * 路由配置
 * 将此文件内容配置到项目的urlManager的rules规则下
 * 也可在main.php文件中 添加
 * ```
 * $dir = __DIR__ . "/route";
 * $main = RbacHelper::addRoute($dir, $main);
 * return $main;
 * ```
 * 引入路由文件 直接将此文件放到config/route/rbac_route.php
 */
$rules = [
    /* 业务代码 */


    /**
     * 部门管理
     */
    ['class' => 'yii\rest\UrlRule',
        'controller' => 'v1/department',
        'pluralize' => false,
        'extraPatterns'=>[
            'POST create' => 'create',
            'GET index' => 'index',
            'GET list' => 'list',
            'GET view' => 'view',
            'GET menu' => 'menu', // 下拉菜单
        ],
    ],
    /**
     * 资产管理 - 台账
     */
    ['class' => 'yii\rest\UrlRule',
        'controller' => 'v1/assets/assets',
        'pluralize' => false,
        'extraPatterns'=>[
            'POST create' => 'create',
            'GET index' => 'index',
            'GET list' => 'list',
            'GET view' => 'view',
        ],
    ],

    /**
     * 资产管理 - 分类
     */
    ['class' => 'yii\rest\UrlRule',
        'controller' => 'v1/assets/assets-cate',
        'pluralize' => false,
        'extraPatterns'=>[
            'POST create' => 'create',
            'GET index' => 'index',
            'GET list' => 'list',
            'GET tree' => 'tree',
            'GET select-tree' => 'select-tree',
            'GET view' => 'view',
        ],
    ],
    /**
     * 标签管理
     */

    ['class' => 'yii\rest\UrlRule',
        'controller' => 'v1/app-label',
        'pluralize' => false,
        'extraPatterns'=>[
            'POST create' => 'create',
             'GET index' => 'index',
            'GET list' => 'list',
            'GET view' => 'view',
        ],
    ],

    /**
     * 授权
     */
    ['class' => 'yii\rest\UrlRule',
        'controller' => 'v1/auth',
        'except' => ['delete', 'create', 'update', 'view'],
        'pluralize' => false,
        'extraPatterns' => [
            'POST login' => 'login', // 登录
            'POST signup' => 'signup', // 注册
        ]

    ],


    ['class' => 'yii\rest\UrlRule',
        'controller' => 'v1/api-article',
        'pluralize' => false,
        'ruleConfig'=>[
            'class'=>'yii\web\UrlRule',
            'defaults'=>[
                'expand'=>'author',
            ]
        ],
        'extraPatterns'=>[
            'POST search' => 'search'
        ],
    ],

    // 测试
    ['class'=>'yii\rest\UrlRule',
        'controller'=>'test',
        // 禁止的action
        'except'=>['delete','create','update','view'],
        'pluralize'=>false,
        'extraPatterns' => [
            'GET test' => 'test',
        ]
    ],
    // 测试content db2
    ['class'=>'yii\rest\UrlRule',
        'controller'=>'content',
        'extraPatterns' => [
            'GET index' => 'index',
            'GET view' => 'view',
            'PUT update' => 'update',
            'POST create' => 'create',
            'DELETE delete' => 'delete',
            'OPTIONS options' => 'options',
            'POST add' => 'add',
            'PUT edit' => 'edit',
        ]
    ],

    ['class'=>'yii\rest\UrlRule',
        'controller'=>'top10',
        'except'=>['delete','create','update','view'],
        'pluralize'=>false,
    ],

    ['class'=>'yii\rest\UrlRule',
        'controller'=>'adminuser',
        'except'=>['delete','create','update','view'],
        'pluralize'=>false,
        'extraPatterns' => [
            'POST login' => 'login',
            'POST signup' => 'signup',
        ]

    ],
    // CSDN 测试user登录
    ['class'=>'yii\rest\UrlRule',
        'controller'=>'user',
        'except'=>['delete','create','update','view'],
        'pluralize'=> true,
        'extraPatterns' => [
            'POST login' => 'login',
            'POST signup' => 'signup',
            'GET list' => 'list'
        ]

    ],

    ['class'=>'yii\rest\UrlRule',
        'controller'=>'v1/user',
        'except'=>['delete','create','update','view'],
        'pluralize' => true,
        'extraPatterns' => [
            'POST login' => 'login',
            'POST signup' => 'signup',
            'GET list' => 'list',
        ],
    ],

    // 文章分类、标签
    ['class' => 'yii\rest\UrlRule',
        'controller' => 'v1/postclass',
        'pluralize' => false,
        'extraPatterns' => [
            'GET index' => 'index',
            'GET list' => 'list',
            'GET my' => 'my',
        ],
    ],

    // 文章分类 2021年8月20日 15:53:02
    ['class' => 'yii\rest\UrlRule',
        'controller' => 'v1/api-category',
        'pluralize' => false,
        'extraPatterns' => [
            'GET index' => 'index',
            'GET my' => 'my',
            'GET list' => 'list',
            'GET my-list' => 'my-list',
        ],
    ],
    // 文章列表
    ['class'=>'yii\rest\UrlRule',
        'controller'=>'v1/api-article',
        'pluralize'=>false,
        'ruleConfig'=>[
            'class'=>'yii\web\UrlRule',
            'defaults'=>[
                'expand'=>'author.userinfo',
            ]
        ],
        'extraPatterns' => [
            'GET index' => 'index',
            'GET list' => 'list',
            'GET view' => 'view',
        ],
    ],

    // 文章关注
    ['class'=>'yii\rest\UrlRule',
        'controller'=>'v1/user-association',
        'pluralize'=> false,
        'ruleConfig'=>[
            'class'=>'yii\web\UrlRule',
            'defaults'=>[
                'expand'=>'',
            ]
        ],
        'extraPatterns' => [
            'GET index' => 'index',
            'GET view' => 'view',
            'GET update-author' => 'update-author',
            'POST create' => 'create',
            'DELETE delete' => 'delete',
        ],
    ],

    // 评论
    ['class'=>'yii\rest\UrlRule',
        'controller'=>'v1/comment',
        'pluralize'=> true,
        'ruleConfig'=>[
            'class'=>'yii\web\UrlRule',
            'defaults'=>[
                'expand'=>'',
            ]
        ],
        'extraPatterns' => [
            'GET index' => 'index',
            'GET view' => 'view',
            'POST create' => 'create',
            'DELETE delete' => 'delete',
        ],
    ],


    ['class'=>'yii\rest\UrlRule',
        'controller'=>'v2/article',
    ],

    ['class'=>'yii\rest\UrlRule',
        'controller'=>'v3/article',
        'extraPatterns' => [
            'GET index' => 'index',
        ]
    ],

    ['class'=>'yii\rest\UrlRule',
        'controller'=>'v4/default',
        'extraPatterns' => [
            'GET index' => 'index',
        ]
    ],
];

return $rules;
